//
//  ItemDetailViewController.m
//  WeatherCast
//
//  Created by long on 15/1/24.
//  Copyright (c) 2015年 anlong. All rights reserved.
//

#import "ItemDetailViewController.h"
#import "WeatherInfoItem.h"

@interface ItemDetailViewController ()

@end

@implementation ItemDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.textDetail = [[UITextView alloc]initWithFrame:self.view.frame];
    
    self.textDetail.editable = NO;
    self.textDetail.font = [UIFont boldSystemFontOfSize:20.0f];
    
    [self.view addSubview:self.textDetail];
    
    self.view.backgroundColor = [UIColor whiteColor];
    NSLog(@"current city name :[%@]", self.currentCityName);
    
    if (self.currentCityName != nil) {
        self.title = self.currentCityName;
    }
    
    // 显示数据
    if(self.weatherInfoData != nil) {
        // 拼接字符串
        // 格式：第一行：PM2.5
        // 各项指数：
        // 格式：第二行：旅游: 适宜
        // 格式：第三行：感冒：较易发
        // 格式：第四行: 运动：较适宜
        // 格式：第五行: 紫外线强度: 最弱
        // 天气情况：
        // 日期、天气、风力、气温
        
        NSString* infos = [[NSString alloc]init];
        //
        
        
        for (NSInteger i=0; i < [self.weatherInfoData.itemWeatherInfo count]; i++) {
            WeatherData* data = [self.weatherInfoData.itemWeatherInfo objectAtIndex:i];
            infos = [infos stringByAppendingFormat:@"日期：%@\n天气：%@\n风力：%@\n温度：%@\n\n", data.date, data.weather, data.wind, data.temperature];
        }
        
        NSString* text = [[NSString alloc]initWithFormat:@"pm2.5: %@\n近期天气状况\n%@", self.weatherInfoData.itemPM25, infos];
        
        self.textDetail.text = text;
    }
    
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
